<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <input type="text" id="textarea"><br>
    <script>
        var textarea = document.getElementsByTagName("input");
        for(var i = 0; i < textarea.length; i++){
            textarea[i].onfocus = function(){
                for(var j = 0; j < textarea.length ; j++){
                    textarea[j].style.backgroundColor = "";
                }
                this.style.backgroundColor = "gray";
            }
        }
    </script>
</body>
</html>